import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'ant-design-vue',
          esModule: true,
          resolveStyle: (name) => {
            return `ant-design-vue/es/${name}/style/css`
          }
        }
      ]
    })
  ],
  server: {
    port: 1874,
    proxy: {
      '/api': {
        target: 'http://localhost:3000/',
        ws: true,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
  resolve: {
    // https://vitejs.dev/config/#resolve-alias
    alias: {
      '@': '/src',
      views: '@/views'
    }
  },
  css: {
    // modules: false
    preprocessorOptions: {
      less: {
        additionalData: "@import './src/assets/css/index.less';"
      }
    }
  }
})
